<template>
  <view class="shop-card-list" :class="isDark?'dark':''" :style="{'background-color':isDark?'#1c1c1c':'#ffffff'}" @tap="shopInfo(item)">
    <image class="shop-img" :src="item.imgurl" mode="aspectFill"></image>
    <view class="shop-info">
      <view class="shop-title text-cut">{{ item.title || $t('comp.shopcardlist.untitledproduct') }}</view>
      <view class="shop-price">￥{{ item.price }}</view>
      <view class="shop-sell-num">
        <text v-if="showFields.includes('sellNum')">{{$t('global.salevolume') + ':' + item.sellNum }}</text>
        <text v-if="showFields.includes('num')" style="margin-left: 16rpx;">{{$t('global.stock') + ':' + item.num }}</text>
      </view>
    </view>
  </view>
</template>

<script>
import darkModeMixin from '@/utils/darkModeMixin.js'
export default {
  mixins: [darkModeMixin],
  name: 'shopCardList',
  props: {
    item: {
      type: Object,
      required: true
    },
    showFields: {
      type: Array,
      default: () => ['sellNum', 'num']
    }

  },
  methods: {
    shopInfo(data) {
      var that = this;
      uni.navigateTo({
        url: '/pages/shop/shopinfo?sid=' + data.id
      });
    }
  }
}
</script>

<style scoped>
.shop-card-list {
  display: flex;
  width: 100%;
  background: #fff;
  border-radius: 18rpx;
  box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.06);
  margin-bottom: 18rpx;
  overflow: hidden;
  align-items: center;
}
.shop-img {
  width: 200rpx;
  height: 200rpx;
  object-fit: cover;
  border-radius: 18rpx 0 0 18rpx;
  flex-shrink: 0;
}
.shop-info {
  flex: 1;
  padding: 18rpx 16rpx 12rpx 16rpx;
  display: flex;
  flex-direction: column;
  gap: 8rpx;
}
.shop-title {
  font-size: 28rpx;
  font-weight: bold;
  color: #222;
  margin-bottom: 6rpx;
}
.shop-price {
  color: #e4393c;
  font-size: 26rpx;
  font-weight: bold;
}
.shop-sell-num {
  color: #888;
  font-size: 22rpx;
  margin-top: 2rpx;
}
.shop-shop {
  color: #999;
  font-size: 22rpx;
}
.text-cut {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style> 